﻿{extend name="public:base" /}

{block name="css"}
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css"/>
<link rel="stylesheet" type="text/css" href="__ADMIN__/css/style.css">{/block}{block name="content"}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <form method="post">
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">名称</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="name" placeholder="请输入名称" value="{$info.name}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">等级（只用于数字显示）</label>
                                <div class="col-sm-3">
                                    <input type="number" class="form-control" name="level_num" placeholder="请输入等级" value="{$info.level_num}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">封面图</label>
                                <div class="col-sm-6">
                                    <input type="file" id="img_file" accept="image/*" style="display: none">
                                    <input type="hidden" class="hidden_value" name="img" id="img" value="{$info['img']|default=''}"/>
                                    <div class="btn btn-w-m btn-primary" onclick="uploadImage('img_file', 'img', 'form-uploaded-box-single', false, 1)">原图上传</div>
                                    <div class="btn btn-w-m btn-primary" onclick="openCrop('form-uploaded-box-single', 1)">裁剪上传</div>

                                    <div class="form-uploaded-box" id="form-uploaded-box-single" style="width: 140px">
                                        {if $info.img}
                                        <div class="form-uploaded-img-box">
                                            <img class="form-uploaded-box-img" src="{:getPicture($info.img)}" data-id="{$info.img}">
                                            <i class="form-uploaded-img-preview iconfont icon-yulan" onclick="previewImg(this, 'form-uploaded-img-preview')"></i>
                                            <i class="form-uploaded-img-del iconfont icon-close" onclick="delImage(this, 'cropper_uploaded_img_ids', 'cropper_uploaded_img_paths', 'form-')"></i>
                                        </div>
                                        {/if}
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">价格</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="price" placeholder="请输入价格" value="{$info.price}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">分佣比例</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="rate" placeholder="请输入分佣比例" value="{$info.rate}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">有效期（天）</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control use_day" name="use_day" placeholder="请输入有效期，填0表示活动服务，不可查看用户资料" value="{$info.use_day}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item look_count_item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">每天可查看用户资料次数</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control look_count" name="look_count" placeholder="请输入每天可查看用户资料次数" value="{$info.look_count}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item look_count_item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">每天可主动聊天人数</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control chat_count" name="chat_count" placeholder="请输入每天可主动聊天人数" value="{$info.chat_count}">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">指定角色可看</label>
                                <div class="col-sm-3 layui-form">
                                    <select name="role_id">
                                        <option value="0">所有角色</option>
                                        {volist name="role_list" id="vo"}
                                        <option value="{$vo.id}" {$info.role_id== $vo.id ?
                                        'selected' : ''}>{$vo.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="row">
                                <label class="col-sm-1 col-form-label">内容</label>
                                <div class="col-lg-6">
                                    <div class="ibox ">
                                        <textarea id="editor_id">{$info.content}</textarea>
                                        <textarea name="content" data-editor="kindEditor" style="display: none"></textarea>
                                    </div>
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row layui-form">
                                <label class="col-lg-1 col-form-label">状态</label>
                                <div class="col-lg-3">
                                    <input type="radio" name="status" value="1" title="启用" {$info.status !=2 ? 'checked' : ''}>
                                    <input type="radio" name="status" value="2" title="禁用" {$info.status== 2 ? 'checked' : ''}>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <input type="hidden" name="id" value="{:input('id')}">

                        <div class="form-group row">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button type="button" class="btn btn-w-m btn-default back-page">返回</button>
                                <button type="button" class="btn btn-w-m btn-primary ajax-post">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/cropper-img-mask" cropper_uploaded_img_ids="cropper_uploaded_img_ids" cropper_uploaded_img_paths="cropper_uploaded_img_paths" crop_preview_box="crop-preview-box" /}{include file="public/preview-img-mask" swiper-id="cropper-preview" /}{/block}

{block name='js'}
<script src="__STATIC__/layui/layui.js"></script>
<script type="text/javascript" src="__PLUG__/kindeditor/kindeditor-all.js"></script>
<script>
    <!-- 实例化编辑器 -->
    initKindEditor('editor_id');

    var use_day = $('.use_day').val();
    if (use_day <= 0) $('.look_count_item').hide();

    $('.use_day').on('input', function () {
        var use_day = $(this).val();

        if (use_day <= 0) {
            $('.look_count').val(0);
            $('.look_count_item').hide();
        } else {
            $('.look_count_item').show();
        }
    })

</script>{/block}
